package com.liqing.movecomment.controller;

import com.github.pagehelper.PageInfo;
import com.liqing.movecomment.entity.Score;
import com.liqing.movecomment.service.ScoreService;
import com.liqing.movecomment.vo.ScoreTagVo;
import com.liqing.movecomment.vo.ScoreVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
 * (Score)表控制层
 *
 * @author makejava
 * @since 2023-05-08 02:16:16
 */
import com.liqing.movecomment.annotation.ResponseResult;

import java.util.List;

@ResponseResult
@Api(tags = "score√")
@RequestMapping("score")
public class ScoreController {
    /**
     * 服务对象
     */
    @Resource
    private ScoreService scoreService;

    /**
     * 分页查询
     *
     * @param page 页码
     * @param size 页长
     * @return 查询结果
     */

    @ApiOperation("我的 电影评分记录")
    @GetMapping("myScore")
    public PageInfo<ScoreVo> queryAll(Integer page, Integer size) {
        return this.scoreService.queryAll(page, size);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */

    @GetMapping("{id}")
    public ScoreVo queryById(@PathVariable("id") Integer id) {
        return this.scoreService.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param score 实体
     * @return 新增结果
     */
    @PostMapping
    public Score add(@RequestBody Score score) {
        return this.scoreService.insert(score);
    }

    /**
     * 编辑数据
     *
     * @param score 实体
     * @return 编辑结果
     */
    @PutMapping
    public Score edit(Score score) {
        return this.scoreService.update(score);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public Boolean deleteById(Integer id) {
        return this.scoreService.deleteById(id);
    }

    @GetMapping("getScore")
    public Score getScore(Integer movieId, Integer tagId) {
        return this.scoreService.getScore(movieId, tagId);
    }

    @GetMapping("getScoreByMovieId")
    public List<ScoreTagVo> getScoreByMovieId(Integer movieId) {
        return this.scoreService.getScoreByMovieId(movieId);
    }


}

